<script type="text/javascript">
  en4.core.runonce.add(function(){

    <?php if( !$this->renderOne ): ?>
    var anchor = $('who_i_viewed').getParent();

    $('who_i_viewed_previous').style.display = '<?php echo ( $this->visits->getCurrentPageNumber() == 1 ? 'none' : '' ) ?>';
    $('who_i_viewed_next').style.display = '<?php echo ( $this->visits->count() == $this->visits->getCurrentPageNumber() ? 'none' : '' ) ?>';

    $('who_i_viewed_previous').removeEvents('click').addEvent('click', function(){
      en4.core.request.send(new Request.HTML({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        data : {
          format : 'html',
          subject : en4.core.subject.guid,
          page : <?php echo sprintf('%d', $this->visits->getCurrentPageNumber() - 1) ?>
        }
      }), {
        'element' : anchor
      })
    });

    $('who_i_viewed_next').removeEvents('click').addEvent('click', function(){
      en4.core.request.send(new Request.HTML({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        data : {
          format : 'html',
          subject : en4.core.subject.guid,
          page : <?php echo sprintf('%d', $this->visits->getCurrentPageNumber() + 1) ?>
        }
      }), {
        'element' : anchor
      })
    });
    <?php endif; ?>
  });
</script>

<ul class='visits generic_list_widget' id="who_i_viewed">
<?php foreach( $this->visits as $visit ): ?>
<?php $user = Engine_Api::_()->user()->getUser($visit->profile_id); ?>
<li>
    <div class="photo">
    <?php echo $this->htmlLink($user->getOwner()->getHref(), $this->itemPhoto($user->getOwner(), 'thumb.icon', $user->getOwner()->getTitle()), array('class' => 'thumb')) ?>
    </div>
    <div class="info">
        <div class="title">
        <?php echo $this->htmlLink($user->getOwner()->getHref(), $user->getOwner()->getTitle()) ?>
        </div>
        <div class="stats">
            <?php echo $this->translate('Last view');?>: <?php echo $this->timestamp($visit->visit_date) ?>
        </div>
        <div class="owner">
        <span><?php echo $this->translate(array('%s view', '%s views', $visit->visit_count), $this->locale()->toNumber($visit->visit_count)) ?></span>
        </div>
      </div>
</li>
<?php endforeach; ?>
</ul>  

<div style="float:none;clear:both;"></div>
<div>
  <div id="who_i_viewed_previous" class="paginator_previous">
    <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Previous'), array(
      'onclick' => '',
      'class' => 'buttonlink icon_previous'
    )); ?>
  </div>
  <div id="who_i_viewed_next" class="paginator_next">
    <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Next'), array(
      'onclick' => '',
      'class' => 'buttonlink icon_next'
    )); ?>
  </div>
</div>